package nowCoder;

import java.util.Scanner;

public class HJ65 {
    /*
    sicctaooeswtvhhprjbmetnbxcwbvtlmdx
    fosvhxthbogolkosjkyqbwfobxygscryqknsgamjqqygheyoqhnlpjxmilvfjrdwnbplfuw

    nvlrzqcjltmrejybjeshffenvkeqtbsnlocoyaokdpuxutrsmcmoearsgttgyyucgzgcnurfbubgvbwpyslaeykqhaaveqxijc
    wkigrnngxehuiwxrextitnmjykimyhcbxildpnmrfgcnevjyvwzwuzrwvlomnlogbptornsybimbtnyhlmfecscmojrxekqmj
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        String ll;
        if (a.length()>b.length()){
            ll = b;
            b = a;
            a = ll;
        }
        ll = "";
        for (int i = 0; i < a.length(); i++) {
            char c = a.charAt(i);
            for (int j = 0; j < b.length(); j++) {
                char cc = b.charAt(j);
                if (c == cc){
                    int l = 1;
                    int x = i+1;
                    int y = j+1;
                    while(true){
                        if (x >= a.length() || y >= b.length() || a.charAt(x) != b.charAt(y)){
                            if (l > ll.length())
                                ll = a.substring(i,x);
                            break;
                        }
                        l++;
                        x++;
                        y++;
                    }
                }
            }
        }
        System.out.println(ll);
    }
}
